entry: Measure icons again
authorTimm Bäder <mail@baedert.org>
Sun, 21 Jul 2019 07:58:08 +0000 (09:58 +0200)
committerTimm Bäder <mail@baedert.org>
Sun, 21 Jul 2019 07:58:08 +0000 (09:58 +0200)
This was previously removed because it changes the minimum and natural
size of the entry when the icons are shown/hidden at runtime. Just not
measuring them does not work however, so reintroduce this.

gtk/gtkentry.c

index b746537ba4d59719b7fc9820471609e6b9eb696d..16ca45c10616836b9d644b9bf3a0030226475148 100644 (file)
@@ -1529,6 +1529,7 @@ gtk_entry_measure (GtkWidget      *widget,
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
+  int i;
 
   gtk_widget_measure (priv->text,
                       orientation,
@@ -1536,6 +1537,30 @@ gtk_entry_measure (GtkWidget      *widget,
                       minimum, natural,
                       minimum_baseline, natural_baseline);
 
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+      int icon_min, icon_nat;
+
+      if (!icon_info)
+        continue;
+
+      gtk_widget_measure (icon_info->widget,
+                          GTK_ORIENTATION_HORIZONTAL,
+                          -1, &icon_min, &icon_nat, NULL, NULL);
+
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          *minimum += icon_min;
+          *natural += icon_nat;
+        }
+      else
+        {
+          *minimum = MAX (*minimum, icon_min);
+          *natural = MAX (*natural, icon_nat);
+        }
+    }
+
   if (priv->progress_widget && gtk_widget_get_visible (priv->progress_widget))
     {
       int prog_min, prog_nat;